home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
1svga.zip
/
LINE320.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-04-21
|
1KB
|
43 lines
uses Txt;
{ ─────────────── Line320 ─────────────── }
procedure Line320(X1,Y1,X2,Y2,Color:integer);
const
MinX:integer=0; MinY:integer=0;
MaxX:integer=320; MaxY:integer=200;
var M,I,D,Dx,Dy,IncX,IncY,IncA,IncB:integer;
begin
if ((Y1<MinY) and (Y2<MinY)) or ((Y1>MaxY) and (Y2>MaxY))
or ((X1<MinX) and (X2<MinX)) or ((X1>MaxX) and (X2>MaxX)) then Exit;
if X1<MinX then X1:=MinX; if X1>MaxX then X1:=MaxX;
if X2<MinX then X2:=MinX; if X2>MaxX then X2:=MaxX;
if Y1<MinY then Y1:=MinY; if Y1>MaxY then Y1:=MaxY;
if Y2<MinY then Y2:=MinY; if Y2>MaxY then Y2:=MaxY;
Dx:=Abs(X2-X1); Dy:=Abs(Y2-Y1);
if Dx>=Dy then begin
if X2>X1 then IncX:=1 else IncX:=-1;
if Y2>Y1 then IncY:=320 else IncY:=-320;
end else begin
D:=Dx; Dx:=Dy; Dy:=D;
if X2>X1 then IncY:=1 else IncY:=-1;
if Y2>Y1 then IncX:=320 else IncX:=-320;
end;
D:=Dy shl 1-Dx; IncA:=D-Dx; IncB:=D+Dx;
M:=320*Y1+X1;
for I:=0 to Dx do begin
Mem[$A000:M]:=Color;
Inc(M,IncX);
if D>=0 then begin Inc(D,IncA); Inc(M,IncY); end
else Inc(D,IncB);
end;
end;
var I:integer;
begin
VideoMode($13);
for I:=0 to 999 do
Line320(160,100,Random(320),Random(200),I div 20+32);
Readln;
VideoMode(3);
end.